function commit(){
	var caption=document.getElementById("caption").value;
	var state=document.getElementById("state").value;
	var time=document.getElementById("time").value;
	var json_commit_teacher="{\"teacher\":[";
	var flag=true;
	for(var i=0;i<at.length;++i){
		var te=document.getElementById("t"+at[i]);
		if(te.checked==true){
			if(flag==true){
				json_commit_teacher+="{\"id\":\""+at[i]+"\"}";
				flag=false;
			}else{
				json_commit_teacher+=",{\"id\":\""+at[i]+"\"}";
			}
		}
	}
	json_commit_teacher+="]}";
	var json_commit_student="{\"student\":[";
	flag=true;
	for(var i=0;i<as.length;++i){
		var ts=document.getElementById("s"+as[i]);
		if(ts.checked==true){
			if(flag==true){
				json_commit_student+="{\"id\":\""+as[i]+"\"}";
				flag=false;
			}else{
				json_commit_student+=",{\"id\":\""+as[i]+"\"}";
			}
		}
	}
	json_commit_student+="]}";
	var commit_post="id="+id+"&caption="+caption+"&state="+state+"&time="+time+"&teacher="+json_commit_teacher+"&student="+json_commit_student;
	var ajax=new XMLHttpRequest();
	ajax.onreadystatechange=function(){
		if(ajax.readyState==4 && ajax.status==200){
			if(ajax.responseText=="succes"){
				if(confirm("操作成功，返回上一个操作页面 or 继续编辑，返回？")==true){
					window.history.go(-1);
				}
			}else{
				alert(ajax.responseText);
			}
		}
	};
	ajax.open("post", "./EditTest", true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send(commit_post);
}

function edit_student(){
	var button=document.getElementById("edit_student_button");
	var edit_div=document.getElementById("edit_student");
	if(button.innerHTML=="展开编辑"){
		button.innerHTML="收起编辑";
		edit_div.style.display="";
	}else{
		button.innerHTML="展开编辑";
		edit_div.style.display="none";
	}
}

function edit_teacher(){
	var button=document.getElementById("edit_teacher_button");
	var edit_div=document.getElementById("edit_teacher");
	if(button.innerHTML=="展开编辑"){
		button.innerHTML="收起编辑";
		edit_div.style.display="";
	}else{
		button.innerHTML="展开编辑";
		edit_div.style.display="none";
	}
}

function go_back() {
	window.history.go(-1);
}
